home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / private / _clrupda.c < prev    next >
C/C++ Source or Header  |  1993-10-30  |  4KB  |  169 lines

  1. #ifndef NO_MEMORY_H
  2. #include <memory.h>
  3. #endif
  4. #define    CURSES_LIBRARY    1
  5. #include <curses.h>
  6.  
  7. #ifdef PDCDEBUG
  8. char *rcsid__clrupda = "$Header: C:\CURSES\private\RCS\_clrupda.c 2.1 1993/06/18 20:22:48 MH Rel MH $";
  9. #endif
  10.  
  11.  
  12.  
  13.  
  14. /*man-start*********************************************************************
  15.  
  16.   PDC_clr_update()    - Updates the screen with a full redraw.
  17.  
  18.   PDCurses Description:
  19.      Updates the screen by clearing it and then redraw it in its
  20.      entirety. If _cursvar.refrbrk is TRUE, and there is pending
  21.      input characters, the update will be prematurely terminated.
  22.  
  23.   PDCurses Return Value:
  24.      This routine returns ERR if it is unable to accomplish it's task.
  25.      This return value is ONLY under FLEXOS.
  26.  
  27.      The return value OK is returned if there were no errors.
  28.  
  29.   PDCurses Errors:
  30.      No errors are defined for this function.
  31.  
  32.   Portability:
  33.      PDCurses    int PDC_clr_update( WINDOW* s );
  34.  
  35. **man-end**********************************************************************/
  36.  
  37. int    PDC_clr_update(WINDOW *s)
  38. {
  39. register int    i;
  40. register int    j;
  41.     WINDOW*    w;
  42.     chtype*    ch;
  43.  
  44. #if defined(DOS)
  45. #  if SMALL || MEDIUM
  46. struct SREGS segregs;
  47. int ds;
  48. #  endif
  49. #endif
  50.  
  51. #ifdef    FLEXOS
  52.     char    line[80];
  53.     char    attr[80];
  54.     FFRAME    sframe;
  55.     RECT    drect,
  56.         srect;
  57. #endif
  58.  
  59.     extern unsigned    char atrtab[MAX_ATRTAB];
  60.     chtype temp_line[256]; /* this should be enough for the maximum width of a screen. MH-920715 */
  61.     chtype chr;
  62.  
  63. #ifdef PDCDEBUG
  64.     if (trace_on) PDC_debug("PDC_clr_update() - called\n");
  65. #endif
  66.  
  67.     w = curscr;
  68.     if (w == (WINDOW *)NULL)
  69.         return( ERR );
  70.     if (_cursvar.full_redraw)
  71.         PDC_clr_scrn(s); /* clear physical screen */
  72.  
  73.     s->_clear = FALSE;
  74.     for (i = 0; i < LINES; i++)    /* update physical screen */
  75.     {
  76.         if (s != w)    /* copy s to curscr */
  77.  
  78.             memcpy(w->_y[i], s->_y[i], COLS * sizeof(chtype));
  79.  
  80.     ch = temp_line; /* now have ch pointing to area to contain real attributes. MH-920715 */
  81.  
  82.         memcpy(ch,s->_y[i],COLS*sizeof(chtype)); /* copy current line to temp_line. MH-920715 */
  83.  
  84. #ifndef UNIX
  85.         for (j=0;j<COLS;j++)          /* for each chtype in the line... */
  86.            {
  87.             chr = temp_line[j] & A_CHARTEXT;
  88.             temp_line[j] = chtype_attr(temp_line[j]) | chr;
  89.            }
  90. #endif
  91.  
  92.         if (_cursvar.direct_video)
  93.         {
  94. #ifdef    FLEXOS
  95.             PDC_split_plane(w, &line[0], &attr[0], i, 0, i, COLS);
  96. /* need to translate attr[] array to real attributes before displaying it. MH-920715 */
  97.             drect.r_row = i;
  98.             drect.r_col = 0;
  99.             drect.r_nrow = 1;
  100.             drect.r_ncol = COLS;
  101.  
  102.             sframe.fr_pl[0] = (UBYTE *) line;
  103.             sframe.fr_pl[1] = (UBYTE *) attr;
  104.             sframe.fr_nrow = 1;
  105.             sframe.fr_ncol = COLS;
  106.             sframe.fr_use = 0x03;
  107.  
  108.             srect.r_col = 0;
  109.             srect.r_row = 0;
  110.             srect.r_nrow = 1;
  111.             srect.r_ncol = COLS;
  112.  
  113.             s_copy(0x03, 0x01L, 0L, (far unsigned short *) &drect,
  114.                 (far unsigned short *) &sframe,
  115.                 (far unsigned short *) &srect);
  116. #endif
  117.  
  118. #ifdef    DOS
  119. #  ifdef GO32
  120.             dosmemput (ch, COLS * sizeof(chtype),
  121.                 (void *)_FAR_POINTER(_cursvar.video_seg,
  122.                 _cursvar.video_ofs + (i * COLS * sizeof(chtype))));
  123. #  else
  124. #    if    (SMALL || MEDIUM)
  125.         segread(&segregs);
  126.         ds = segregs.ds;
  127.         movedata(ds, (int)ch,
  128.                 _cursvar.video_seg,
  129.                 _cursvar.video_ofs + (i*COLS*sizeof(chtype)),
  130.                     (COLS * sizeof(chtype)));
  131. #    else
  132.             memcpy((void *)_FAR_POINTER(_cursvar.video_seg,
  133.               _cursvar.video_ofs + (i * COLS * sizeof(chtype))),
  134.                    ch, (COLS * sizeof(chtype)));
  135. #    endif
  136. #  endif
  137. #endif
  138.  
  139. #ifdef    OS2
  140.                 VioWrtCellStr ((PCH)ch, (USHORT)(COLS * sizeof(chtype)), (USHORT)i, 0, 0);
  141. #endif
  142.         }
  143.         else
  144.         {
  145.  
  146. #ifdef UNIX
  147.             PDC_gotoxy(i, 0);
  148.             for (j = 0; j < COLS; j++)
  149.             {
  150.                 PDC_putc( (*ch & A_CHARTEXT), (*ch & A_ATTRIBUTES) );
  151.                 ch++;
  152.             }
  153. #else
  154.             for (j = 0; j < COLS; j++)
  155.             {
  156.                 PDC_gotoxy(i, j);
  157.                 PDC_putc( (*ch & A_CHARTEXT), (*ch & A_ATTRIBUTES) >> 8 );
  158.                 ch++;
  159.             }
  160. #endif
  161.         }
  162.  
  163.     if (_cursvar.refrbrk && PDC_check_bios_key())
  164.         return(OK);
  165.  
  166.     }
  167.     return( OK );
  168. }
  169.